<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
include_once("inc/TencentTOauth.php");
include_once("inc/SinaTOauth.php");
include_once("inc/NtesTOauth.php");
include_once("inc/SohuTOauth.php");
include_once("inc/DouBanTOauth.php");
include_once("inc/RenRenOauth.php");
header("content-type:text/html; charset=utf-8");

$orgin;
if(isset($_REQUEST["orignrequest"]) && !empty($_REQUEST["orignrequest"]))
{
    $orgin = $_REQUEST["orignrequest"];
}else{
    $orgin = "";
}
Select_Function($orgin);
function Select_Function($orgin){
    switch ($orgin){
        case "qq":
            TencentDirect();  break;
        case "sina":
            SinaDirect();  break;
        case "ntes":
            NtesDirect();  break;
        case "sohu":
            SohuDirect(); break;
        case "douban":
            DouBanDirect();break;
         case "renren":
            RenRenDirect();break;
    }
}

function TencentDirect(){
   $tencent = new TencentTOauth();
   echo $tencent->GetAccessToken($_REQUEST["oauth_verifier"]);
} 

function SinaDirect(){
    $sina = new SinaTOauth();
    echo $sina->GetAccessToken($_REQUEST["oauth_verifier"]);
}

function NtesDirect(){
    $ntes = new NtesTOauth();
    echo $ntes ->GetAccessToken("");
}

function SohuDirect(){
    $sohu = new SohuTOauth();
    echo $sohu ->GetAccessToken($_REQUEST["oauth_verifier"]);
}

function DouBanDirect(){
    $douban = new DouBanTOauth();
    echo $douban ->GetAccessToken("");
}

function RenRenDirect(){
    $renren = new RenRenOauth();
    $arr = $renren->GetAccessToken($_REQUEST["code"]);
    if(is_array($arr)){
        print_r($renren->GetSessionKey($arr["access_token"]));
    }else{
        echo "获取access_token失败";
    }
}
?>
